<template>
  <el-dialog :title="dialogProps.title" :visible.sync="dialogProps.visible" width="700px"
    @open="handleDialogOpen()" v-loading="loading">
    <div slot="title" class="dialog-header">{{ dialogProps.title }}</div>

      <el-row :span="18">

          <el-col :span="8">
              <label>检测项目</label>
          </el-col>

          <el-col :span="8">
              <label>结果</label>
          </el-col>

          <el-col :span="8">
              <label>参考范围</label>
          </el-col>

        </el-row>
        <el-divider></el-divider>

       <el-form :model="member"
      ref="resourceForm" label-width="80px" label-position="right" size="small">
        <el-row :span="18">
          <el-col :span="8">
                <label>身高</label>
          </el-col>

          <el-col :span="8">

                <el-col :span="16"><el-input v-model="member.height"></el-input></el-col>


          </el-col>

           <el-col :span="8">

               <span>150-200</span>

           </el-col>

        </el-row>

        <el-row :span="18">
          <el-col :span="8">
                <label>体重</label>
          </el-col>

          <el-col :span="8">

                <el-col :span="16"><el-input v-model="member.weight"></el-input></el-col>

          </el-col>
           <el-col :span="8">
             <span>80-300</span>
           </el-col>

        </el-row>

        <el-row :span="18">
          <el-col :span="8">
                <label>体温</label>
          </el-col>

          <el-col :span="8">

                <el-col :span="16"><el-input v-model="member.thermometer"></el-input></el-col>

          </el-col>
          <el-col :span="8">
            <span>36.0-37</span>
          </el-col>

        </el-row>

        <el-row :span="18">
          <el-col :span="8">
                <label>腰围</label>
          </el-col>

          <el-col :span="8">

                <el-col :span="16"><el-input  v-model="member.waistline"></el-input></el-col>

          </el-col>
          <el-col :span="8">
            <span>30-100</span>
          </el-col>

        </el-row>

        <el-row :span="18">
          <el-col :span="8">
                <label>臀围</label>
          </el-col>

          <el-col :span="8">

                <el-col :span="16"><el-input v-model="member.hipline"></el-input></el-col>

          </el-col>
          <el-col :span="8">
            <span>30-100</span>
            </el-col>
        </el-row>

        <el-row :span="18">
          <el-col :span="8">
               <label>舒张压</label>
          </el-col>

          <el-col :span="8">

                <el-col :span="16"><el-input v-model="member.dbp"></el-input></el-col>

          </el-col>

          <el-col :span="8">
            <span>60-100</span>
          </el-col>

        </el-row>

        <el-row :span="18">
          <el-col :span="8">
                <label>收缩压</label>
          </el-col>

          <el-col :span="8">

                <el-col :span="16"><el-input v-model="member.sbp"></el-input></el-col>

          </el-col>

          <el-col :span="8">
            <span>90-140</span>
          </el-col>

        </el-row>

      </el-form>

          <span slot="footer" class="dialog-footer">
            <el-button size="small" type="primary" @click="addDyn()">提交</el-button>
            <el-button size="small" type="primary" @click="foreverChange()">上传</el-button>
            <el-button size="small" type="primary" @click="handleDialogClose()">返回</el-button>
          </span>
    </el-dialog>
</template>

<script>
import {updateDynamicinfo,getDynamicinfo,updateDynamicinfoever} from "@/api/luowuwen/member"
export default {
  name: 'inserDyinfo',
    data(){
      return{
        loading:false,
        member:{
          tMemberId:"", //会员id
          height:"",
          weight:"",
          dbp:"",     //舒张压
          sbp:"",    //收缩压
          breth:"",     //呼吸
          thermometer:"", //体温
          waistline:"", //腰围
          hipline:"" //臀围
        },
        dialogProps: {
          visible: false,
          action: '',
          title: ''
        }
      }
    },
    methods:{

      async foreverChange(){
      try{
              let[flag]=await Promise.all([
              updateDynamicinfoever(this.member)
            ])
           this.dialogProps.visible=false;

        }catch(error){
          console.error;
        }
      },
      async getDynamicinfoByid(id){
        try{
              let[Dynamicinfo]=await Promise.all([
              getDynamicinfo(id)
            ])
            this.member=Dynamicinfo.data
            console.log( this.member);
        }catch(error){
          console.error;
        }
      },

      async addDyn(){
        try{
          console.log(this.member)
              let[flag]=await Promise.all([
              updateDynamicinfo(this.member)
            ])
            this.dialogProps.visible=false;

        }catch(error){
          console.error;
        }
      },
      handleDialogOpen(){
       this.dialogProps.visible=true;
      },
      handleDialogClose(){
        this.dialogProps.visible=false;
      }
    },
    mounted: function() {
    this.$nextTick(() => {
        this.$on('openAddMemberinfo', function(id) {
        this.getDynamicinfoByid(id);
        this.dialogProps.action = 'add'
        this.dialogProps.title = '档案上传'
        this.dialogProps.visible = true
      })
    })
  },
}
</script>

<style>

</style>
